﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RadowCore.Models
{
    public class PGNode: ICloneable
    {
        private string m_name;


        public string Name
        {
            get { return m_name; }
            set { m_name = value; }
        }
        private string m_orignator;

        public string Orignator
        {
            get { return m_orignator; }
            set { m_orignator = value; }
        }

        private string m_role;

        public string Role
        {
            get { return m_role; }
            set { m_role = value; }
        }


        private List<PGEdge> m_edges;

        public List<PGEdge> Edges
        {
            get { return m_edges; }
            set { m_edges = value; }
        }

        private DateTime m_EventTimeStamp;

        public DateTime EventTimeStamp
        {
            get { return m_EventTimeStamp; }
            set { m_EventTimeStamp = value; }
        }

        public PGNode()
        {
            
        }
        
        public PGNode(string _name, string _orginator, string _role)
        {
            Name = _name;
            Orignator = _orginator;
            Role = _role;
            Edges = new List<PGEdge>();
        }

        public PGNode(string _name, string _orginator, string _role, DateTime _timeStamp)
        {
            Name = _name;
            Orignator = _orginator;
            EventTimeStamp = _timeStamp;
            Role = _role;
            
            Edges = new List<PGEdge>();
        }

        public void AddEdge( PGEdge edge)
        {
            this.Edges.Add(edge);
            
        }

        public string GetTargetValue(string nodeName)
        {
            foreach (PGEdge e in Edges)
            {
                if (e.TargetNode.Name == nodeName)
                {
                    return e.Value;
                }
                
            }
            return null;
        }

        public Object Clone()
        {
            PGNode newNode = new PGNode
            {
                Name = this.Name,
                Orignator = this.Orignator,
                EventTimeStamp = this.EventTimeStamp,
                Edges = new List<PGEdge>()
            };
            foreach (PGEdge e in this.Edges)
                newNode.Edges.Add((PGEdge)e.Clone());
            return newNode;
        }
       
    }
}
